<?php

namespace App\Models\ZZMed;


use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class ZUser extends ZZMedBaseModel
{
    protected $table = 'z_user';

    protected $guarded = ['id'];

    const CREATED_AT = 'create_at';
    const UPDATED_AT = 'update_at';


    public function userExtend()
    {
        return $this->hasOne(ZUserExtend::class, 'user_id');
    }


    public static function getUserByMobile($mobile){

        return  self::query()->where('cell', $mobile)->first();

    }

    /**
     *  修改手机号操作
     * @param $userId
     * @param $cell
     * @param $oldCell
     * @return bool
     */
    public static function changeCell($userId, $cell, $oldCell){

        ZUser::query()->where('id', $userId)->update(['cell' => $cell]);

        return true;
    }

}